// pages/newspaper/newspaper.js
const API = require("../../http/API")
const http = require("../../http/http")
Page({

    /**
     * 页面的初始数据
     */
    data: {
        newspaperNavList:[
            {
                text:'大触讲座',
                key:'A'
            },
            {
                text:'大触专访',
                key:'B'
            },
            {
                text:'热门大触',
                key:'C'
            }
        ],
        newspaperListone:[],
        newspaperListTwo:[],
        newspaperListThreen:[],
        // 模式 A B C
        pattern:"A"
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        this.setData({ 
            pattern:"A"
        })
        this.getdataOne()
       
    },
    getdataOne(){
        http("https://m.lanqb.com/api/daniu?link=paging&live=3&heat=N&page=1&is_live=1",{
            // limit:this.data.limit,
            // teacher_show:this.data.teacher_show,
        }).then(res=>{
            this.setData({
                newspaperListone:res.data.course.data
            })
            // console.log(res.data.course.data);
        })
    },
    getdataTwo(){
        http("https://m.lanqb.com/api/daniu/interview?link=paging&type=interview&page=1",{
            // limit:this.data.limit,
            // teacher_show:this.data.teacher_show,
        }).then(res=>{
            this.setData({
                newspaperListTwo:res.data.data
            })
            console.log(res.data.data);
        })
    },
    getdataThreen(){
        http("https://m.lanqb.com/api/daniu/lists?link=paging&page=1",{
            // limit:this.data.limit,
            // teacher_show:this.data.teacher_show,
        }).then(res=>{
            this.setData({
                newspaperListThreen:res.data.data
            })
            console.log(res.data.data);
        })
    },
  

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {
       
    },
    option(e){
        if(e.currentTarget.dataset.item === this.data.newspaperNavList[0].text){
            this.setData({ 
                pattern:"A"
            })
           this.getdataOne()
        }
        if(e.currentTarget.dataset.item === this.data.newspaperNavList[1].text){
            this.setData({ 
                pattern:"B"
            })
           this.getdataTwo()
        }
        if(e.currentTarget.dataset.item === this.data.newspaperNavList[2].text){
            this.setData({ 
                pattern:"C"
            })
           this. getdataThreen()
        }
        // console.log(e.currentTarget.dataset.item);
    },
    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})